package com.xb.cloud.company.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xb.cloud.common.constant.DbConstants;
import com.xb.cloud.company.service.client.CompanyService;
import com.xb.cloud.product.service.business.model.Company;
import com.xb.cloud.product.service.business.model.mapper.CompanyMapper;
import com.xb.cloud.service.client.ServiceReturnInfo;
import com.xb.cloud.service.client.ServiceReturnUtils;

@Service
public class CompanyServiceImpl implements CompanyService {

	@Resource
	CompanyMapper companyMapper;

	@Override
	public ServiceReturnInfo isValidCompany(Long companyId) {
		Company company = companyMapper.selectByPrimaryKey(companyId);
		if (company == null) {
			return ServiceReturnUtils.success(false);
		}
		if (DbConstants.isTrue(company.getIsDeleted()) || !DbConstants.isTrue(company.getIsEnabled())) {
			return ServiceReturnUtils.success(false);
		}
		return ServiceReturnUtils.success(true);
	}

}
